const { verifyToken } = require("../../utils/token")
const { encrypt, decrypt } = require("../../utils/crypto")

module.exports = ({ app, router }) => {
    router.get("/getUserInfo", async (req, res) => {
        if (req.headers?.authorization) {
            const userInfo = await verifyToken(req.headers.authorization)
            userInfo.username = encrypt(userInfo.username)
            userInfo.password = encrypt(userInfo.password)
            res.send(userInfo)
        } else {
            res.send("{}")
        }
    })
}
